#ifndef H_A2TV
#define H_A2TV

#ifndef H_A2SYSDEF
# include "a2sysdef.h"
#endif

/*------- a2tv.h - head file for work with display --------*/
#define A2TV_H
#include "a2tvdef.h"          /* TINT, LDSC, WCB, PCB, DOC */
#include "a2grdef.h"                  /* MDESC description */

                             /* WCB flags:     main flags  */
#define WF_ACS    0x01       /* opened window              */
#define WF_ED     0x02       /* editing, else selecting    */
#define WF_NUM    0x04       /* numeral window, else text  */
#define WF_BIG    0x08       /* only big letter            */
#define WF_MOD    0x10       /* was changed (select)       */
#define WF_FR     0x20       /* frame exists               */
#define WF_ALT    0x40     /* alternative window of select */
#define WF_AUT    0x80       /* automatic exit from window */
#define WF_TBL   0x100       /* don't display panel        */
#define WF_MULTI 0x200       /* reserved                   */
#define WF_FCI   0x400 /* after window entering call fch() */
#define WF_FCO   0x800  /* after window exiting call fch() */
#define WF_FCH  0x1000   /* after press any key call fch() */
#define WF_F2   0x2000  /* exit on F2 and fch() processing */
#define WF_HYF  0x4000           /* formatting after input */

#define WF_OBL  0x8000U      /* necessary window           */
                           /* WCB flags: additional flagsn */
#define WF_DATE   0x0001     /* data                       */
#define WF_TIME   0x0002     /* time                       */
#define WF_LOG    0x0004     /* logical (hexadecimal)      */
#define WF_COLB   0x0008     /* point out caps by color    */
#define WF_LOOK   0x0010     /* for show only              */
#define WF_NEW    0x0020     /* window is new              */
#define WF_PART   0x0040     /* window of call to picture  */
#define WF_MAIN   0x0080     /* first window               */
#define WF_READ   0x0100     /* read from base             */
#define WF_WRITE  0x0200     /* write to base              */
#define WF_BASE   0x0300     /* connected with base        */

#define WF_AHELP  0x0400   /* auto-HELP exists             */
#define WF_AHSTR  0x0800   /* save ground before auto-HELP */
#define WF_NOHELP 0x1000                        /* no help */

#define WF_MONEY  0x2000                          /* money */

#define WF_KEY    0x4000             /* key window         */


/* path of window */
typedef struct
       {unsigned char nbase;   /* byte with number of base */
	short flagsn;           /* flags: don't use 0x2020 */
	char reserv[8];                        /* reserved */
	char part[25];      /* name of subordinate picture */
       } PATH;
#define PF_STEP  0x04               /* autocall to picture */
#define PF_TABLE 0x10               /* picture is table    */

/* for numeral editing windows (WF_NUM|WF_ED):             */
/* frm determines number of digits after decimal point     */
/* frm=255 - number without pattern                        */
/* frm=254 - number in exponential form                    */
#define B_LVAR   0x7F
/*=========================================================*/
/* for selective windows (frm & B_LVAR)!=0 returns length  */
/* of word if (frm & ~B_LVAR) words have variable length   */
/*=========================================================*/
/* for text editing windows frm determines                 */

#define WT_DIG   0x0001      /* digits                     */
#define WT_SGN   0x0002      /* + - . E e                  */
#define WT_LAT   0x0004      /* letters of Latin alphabet  */
#define WT_RUS   0x0008      /* letters of Russian alphabet*/
#define WT_DLM   0x0010      /* delimiters: .,";:-?!'/%    */
#define WT_CNT   0x0020      /* control symbols            */
#define WT_USR   0x0040      /* user symbols               */
#define WT_ALL   0x0080      /* any symbols valid          */


#define PF_WHFP  0x01 /* picture type is defined by flags, */
		      /* else by picture names             */
#define PF_STWN  0x02  /* save old screen state            */
/* undesirable to use 0x04, reserved for PF_STEP */
#define PF_NORS  0x08 /* do not recover screen in a2tvread */
/* undesirable to use 0x10, reserved for PF_TABLE */
#define PF_FWAL  0x20 /*in a2tvread search window on ALT_key*/
#define PF_SCRL  0x40             /* display on free space */
#define PF_NODLG 0x80 /* picture doesn't participate in dialogue */
#define PF_CYCLE 0x100         /* picture's windows cycled */
#define PF_MENU  0x200    /* picture for menu, else dialog box */

#define PF_GRAFIC    0x4000                 /* grafic picture */
#define PF_DISPLAY   0x8000U     /* picture is display        */

#define PF_ROOT     0x10000      /* root picture              */
#define PF_BASE     0x20000      /* connected with base       */
#define PF_ACT      0x40000      /* picture is active         */

#define PF_HP    0x01                 /* print on new page */
#define PF_FP    0x02          /* after printing skip page */
#define PF_FIX   0x10    /* size of picture is fixed -     */
			 /*          transfers are blocked */
#define PF_DEV   0x20 /* printing on several pages is legal */
#define PF_NOFRAME 0x40                /* no printing frame */

#define TP_PH  0x8000U                      /* page header */
#define TP_PF  0x4000                          /* page end */
#define TP_FL  0x2000        /* background symbol for page */
#define TP_H   0x1000               /* intermediate header */
#define TP_P   0x0800                            /* period */
#define TP_T   0x0400              /* intermediate outcome */
#define TP_HD  0x0200                   /* document header */
#define TP_FD  0x0100                  /* document outcome */

#define TP_FALL 0xFF00            /* flags of picture type */
#define TP_SP (TP_H | TP_T | TP_HD | TP_FD)

/*p - determines call point and takes the values: WO_BEG,  */
/* WO_END... . Possible answers: WA_CONT, WA_NOST, WA_END  */

#define WO_BEG   0x00 /* fch in beginning of window processing */
#define WO_END   0x02 /* fch in end of window processing       */
#define WO_CHN   0x04         /* fch after window changing     */
#define WO_F2    0x08         /* fch on F2                     */
#define WO_BUSR  0x10         /* fch called by user            */
#define WO_EUSR  0x20         /* fch called by user            */
/* completion codes for exit functions: */
#define WA_CONT  0      /* O'K                             */
#define WA_NOST -1            /*  */
#define WA_END  -2       /* errors, terminate processing   */

#define WO_DISPLAY 0x040
#define WO_READ    0x080
#define WO_PRINT   0x100
/* Possible answers:
 LEFT  UP  DOWN  ENTER  F2  RIGHT  ESC  HOME  END
 or any users keys */

/*-------------- description of level variable:  ----------*/
struct a2level
     {char type;              /* type of variable          */
      void *var;              /* address                   */
      void *old;              /* old value                 */
      int (*filpcb)();        /* fulfillment program       */
      struct a2level *next;   /* next variable             */
     };
typedef struct a2level LEVEL;

/*------------ descriptions of main functions -------------*/
/*      low level functions group for screen output        */
/*         these functions defined in  a2grtxt.h           */

#ifdef __cplusplus
extern "C" {
#endif
/*------------ PROCESSING OF DATA IN LDSC FORMAT ----------*/
/*-- a2ldge - get memory element from LDSC pool -----------*/
void *a2ldge(char *pname);
/* a2ldfe - free memory element from LDSC pool ------------*/
void *a2ldfe(void *el, char *pname);
/*------------------ a2ldclr - substring clearing ---------*/
/* puts '\0' sequence in substring ------------------------*/
a2ldclr(LDSC *ldsc);
/*------- a2ldpcls - clears spaces in end of line ---------*/
a2ldpcls(LDSC *ldsc);
/*------------ a2ldin - puts line in list -----------------*/
void a2ldin(LDSC *ldsco, LDSC *ldscn, char rgm);
   /*---- rgm=a - after, rgm=b - before current -----------*/
/*------------ a2ldgn - new line creation -----------------*/
LDSC *a2ldgn(LDSC *ldsco, char rgm);
   /*---- rgm=a - after, rgm=b - before current -----------*/
/*------------ a2ldns - new substring creation ------------*/
LDSC *a2ldns(LDSC *ldsco, char rgm);
   /*---- rgm=a - after, rgm=b - before current -----------*/
/*------------ a2ldfs - search for line descriptor --------*/
LDSC *a2ldfs(WCB *wcb, char rgm, int i);
  /* rgm=o - existing, rgm=n - with creation; i - number --*/
/*------------ a2ldfc - search for i character in line ----*/
LDSC *a2ldfc(LDSC *ldscs, char rgm, int i, int *k, int *j);
 /* rgm=o/n; numbers: searching-i; found-k; in substring-j */
/*------------ a2ldfm - search for line center ------------*/
a2ldfm(LDSC *ldsc);       /* returns point of line sharing */
/*-------a2ldft - search in substring for table symbol ----*/
a2ldft(LDSC *ldsc, char *tabl, int i, char reg);
/*tabl- symbol table, i-search beginning, reg=n - denial --*/
/*------------- a2ldds - substring removing ---------------*/
LDSC *a2ldds(WCB *wcb, LDSC *ldscs, LDSC *ldscc);
/*- wcb - window descriptor; ldscs - line descriptor;
    ldscc - substring descriptor -*/
/*- a2lddl - actual removing of line / or from list -------*/
LDSC *a2lddl(WCB *wcb, LDSC *ldsc, char rgm);
 /*- wcb - window descriptor;
     ldsc - line descriptor ; rgm-r/d -----*/
/*-------------- a2ldtxtdl - text removing  ---------------*/
LDSC *a2ldtxtdl(LDSC *ldsc);
 /*- ldsc - descriptor of text beginning ------------------*/
/*-------- a2ldflst - search for last line in text --------*/
LDSC *a2ldflst(LDSC *text);
/*--- a2ldlast - removing of last line from text ----------*/
LDSC *a2ldlast(LDSC *ldsc);
                 /* ldsc - descriptor of 1-st line in text */
/*------------ a2ldme - transferring of substring end -----*/
void a2ldme(LDSC *ldscf,int jf,LDSC *ldsct,int jt);
     /* from (substring, number); to (substring, number) --*/
/* a2ldcb - copying of substring picture,
                                   starting from beginning */
void a2ldcb(LDSC *ldscf,int jf,LDSC *ldsct,int jt,int jl);
 /* source (substring, number); destination (substring, number)
         up to (number) */
/* a2ldce - copying of substring picture, starting from end*/
void a2ldce(LDSC *ldscf,int jf,LDSC *ldsct,int jt,int jl);
 /* source (substring, number); destination (substring, number)
         up to (number) */
/*----- a2ldsr - shift of substring by one symbol to right */
LDSC *a2ldsr(LDSC *ldsc,int *j);
/*-------- a2ldcpln - full copying of line ----------------*/
LDSC *a2ldcpln(LDSC *ldsco);
/* ldsco - source line; returns pointer to copy */
/*---------- a2ldlcpy - copying of line -------------------*/
LDSC *a2ldlcpy(LDSC *src, LDSC *dest);
/* src: source; dest: destination (NULL);
                                   returns pointer to copy */
/*--------- a2ldcpt - full copying of text ----------------*/
LDSC *a2ldcpt(LDSC *ldsco);
/* ldsco - source text; returns pointer to it's copy */
/*------------ a2ldtcpy - coping of text ------------------*/
LDSC *a2ldtcpy(LDSC *src, LDSC *dest);
/* src: source; dest: destination (NULL);
                                   returns pointer to copy */
/*--------- a2ldendl - end of line deletion  --------------*/
void a2ldendl(LDSC *ldsc);
     /* beginning of substring to be retained */
/*---------- a2ldfstr - converts of line to ldsc ----------*/
LDSC *a2ldfstr(char *text, LDSC *ldsc);
/*---- text - text line, ldsc - pointer to ldsc or NULL ---*/
/*----- a2ld1ftx - converts text to ldsc by one line ------*/
LDSC *a2ld1ftx(char *text, LDSC *ldsc);
/*- text - text string, ldsc - pointer to ldsc or NULL ----*/
/*--------- a2ldftxt - converts text to ldsc --------------*/
LDSC *a2ldftxt(char *text, LDSC *ldsc);
/* text - text string, ldsc - ldsc beginning or NULL */
/*---------- a2ldtstr - converts string from ldsc ---------*/
void a2ldtstr(LDSC *ldsc, char *text, int ns);
/*- ldsc, text - text string address, ns - maximum length -*/
/*--------- a2ldttxt - converts text from ldsc ------------*/
void a2ldttxt(LDSC *ldsc, char *text, int nt);
/*- ldsc, text - text string address, nt - maximum length -*/
/*---------- a2ldadd - upends ldsc by text  ---------------*/
LDSC *a2ldadd(char reg, LDSC *ldsc, char *text);
/*reg: c - upend current line (pointed by ldsc);*/
/* l - uppend last line ; n - create new line in the end   */
/* of line; b -  create new line in the beginning of text  */
/*------- a2ldwadd - transfers word to end of window ------*/
a2ldwadd(WCB *wcb, char *text);
/* wcb - selecting window of length wcb->frm; if length of */
/* word<wcb->frm, then upends by spaces, else truncates    */
/*--- a2ldfind - search in line required word with step ---*/
LDSC *a2ldfind(char *world,LDSC *ldsc,int *k,int *j,int step);
/* world - word required. Start for search: ldsc -         */
/* substring, k - number of string in line, j-in substring */
/* step - step in text (0 - step in words)                 */
/*------- a2ldfwln - search in line for required word -----*/
LDSC *a2ldfwln(char *world, LDSC *ldsc, int *k, int *j);
/* world - word required, ldsc - start for search,         */
/* k - symbol number in line, j - in substring             */
/*------ a2ldwrln - writing long value number i to LDSC ---*/
a2ldwrln(LDSC *ldsc, int i, long n);
/*------ a2ldrdln - reading long value number i from LDSC -*/
long a2ldrdln(LDSC *ldsc, int i);
/*---- a2ldlen - gets text length in LDSC line ------------*/
/* all symbols counted, ESC-sequences included */
a2ldlen(LDSC *ldsc);
/*- a2ldltxt - gets number of lines in text in LDSC -------*/
/* all symbols counted, ESC-sequences included */
a2ldltxt(LDSC *ldsc); /* ldsc - pointer to text beginning  */
/*  a2ldij - gets number of lines and max. column number   */
void a2ldij(LDSC *text, int *i, int *j);
/*---------- a2ldcmprs - comress text in LDSC -------------*/
void a2ldcmprs(LDSC *ldsc);

/*-----------------------------------------------------------*/
/*- functions for text formatting ---------------------------*/
/*-----------------------------------------------------------*/
#define A2F_SZTBMASK 0x000F /* mask for TABSIZE              */
#define A2F_AUTOPARA 0x0000 /* automatic paragraph begin     */
#define A2F_DSBLPARA 0x0010 /* disable paragraph begin       */
#define A2F_MAKEPARA 0x0030 /* make paragraph begin          */
#define A2F_PARA   (A2F_AUTOPARA | A2F_DSBLPARA | A2F_MAKEPARA)
#define A2F_ENBLSRUS 0x0040 /* enable split for russian words*/
#define A2F_ENBLSLAT 0x0080 /* enable split for latin words  */
#define A2F_DELLASTM 0x0100 /* delete "-" from EOL           */
#define A2F_COMPRGAP 0x0200 /* many spaces converts to one   */
#define A2F_DELSPBLM 0x0400 /* del spaces before delimiters  */
#define A2F_INSSPALM 0x0800 /* insert space after delimiters */
#define A2F_LEFT     0x0000 /* left justified text           */
#define A2F_RIGHT    0x1000 /* right justified text          */
#define A2F_CENTER   0x2000 /* centered text                 */
#define A2F_EXPAND   0x3000 /* text expanded in margins      */
#define A2F_JUST  (A2F_LEFT |A2F_RIGHT |A2F_CENTER |A2F_EXPAND)
#define A2F_BY1LINE  0x4000 /* doesn't concatenate src lines */
#define A2F_MAXL     160
/* #define A2F_HARDNEWL '\x0E' --- NOT YET IMPLEMENTED */

int A2PAS a2formtx (
   int flags,
   int lmargin, int rmargin, int redlin,
   int (*gstr)(char *buf, int maxl), int (*pstr)(char *buf)
);

LDSC *a2hyfen (LDSC *srctxt, int lth);

LDSC *a2hyfen1(LDSC *srctxt, int flags, int lth, int redlin);

extern int a2hyfen_flags;
extern int a2hyfen_indent;

/*-----------------------------------------------------------*/
/*-----------------------------------------------------------*/


/*----- ltin - source text, lth - width of column ---------*/
#define C_WORD   0
#define C_ELINE -1
#define C_ETEXT -2
#define C_EMPTY -3
/*------- a2ldprvw - gets previous word in text -----------*/
a2ldprvw(LDSC *ldsc, int *l, int *c, int (*f)(unsigned char));
/* ldsc - pointer to text beginning, l - line number,      */
/* c - column number, f(lit) - returns 0, if symbol        */
/* belongs to word,  by default (f=NULL) f=chcklit.        */
/* returns: C_WORD - success,  C_ELINE - end of line,      */
/*          C_ETEXT - end of text, C_EMPTY - no text.      */
/*------- a2ldnxtw - next word in text --------------------*/
a2ldnxtw(LDSC *ldsc, int *l, int *c, int (*f)(unsigned char));
/* ldsc - pointer to text beginning, l - line number,      */
/* c - column number, f(lit) - returns 0, if symbol        */
/* belongs to word,  by default (f=NULL) f=chcklit.        */
/* returns: C_WORD - success,  C_ELINE - end of line,      */
/*          C_ETEXT - end of text, C_EMPTY - no text.      */
/* a2ldnwrd - puts word of given length from LDSC to text -*/
a2ldnwrd(LDSC *ldsc, int l, int c, int n, char *text);
/* ldsc - pointer to text beginning, l - line number,      */
/* c - column number, n - word length                      */
/* returns: number of symbols moved, C_EMPTY - no word     */
/*--- a2ldword - word to delimiter from LDSC to text ------*/
a2ldword(LDSC *ldsc, int l, int c, int (*f)(unsigned char), char *text);
/* ldsc - pointer to text beginning, l - line number,      */
/* c - column number, f(lit) - returns 0, if symbol        */
/* belongs to word,  by default (f=NULL) f=chcklit.        */
/* returns: number of symbols moved, C_EMPTY - no word     */
/*---------- WINDOWS  AND  PARTS  PROCESSING --------------*/
#define ER_NODAT -1     /* no data in window               */
#define ER_NOWCB -2     /* the window not found in picture */
#define ER_PTYPE -3     /* wrong data type                 */
#define ER_NOPART -4     /* no such picture in document    */
#define ER_NOMEM -20     /* not enough memory              */
#define ER_TOCONV -100  /* addition to a2conv codes        */
/* ------- for functions a2ptwput and a2pfwget ----------- */
#define TY_RQS   98      /* prefix setting for fulfillment */
#define GW_CURR    0x01   /* start processing from current */
                          /* window, else from first one   */
#define GW_NOCLS   0x02   /* don't process closed windows  */
#define GW_NOOPN   0x04   /* don't process opened windows  */
#define GW_DSPL    0x08   /* display windows               */
#define GW_NOSYS   0x10   /* don't process system windows  */
/*---- a2tvlang - interface language for functions a2tv... */
a2tvlang(void);/* returns:'P'- Russian or 'E'- English     */
/*------------ a2tv0kpc - processing of one window --------*/
a2tv0kpc(WCB *pwcb, char reg, TINT *part, unsigned **bufkey);
/* pwcb - window, reg - regime (w/r/p), picture position   */
/* or pcb bufkey - pointer to code buffer or  NULL         */
/*----- a2tvkset - setting of output symbols list ---------*/
unsigned int *a2tvkset(unsigned int *ar);
/*- returns pointer to old values of output codes ---------*/
/*---------- a2tvprst - old screen recovery ---------------*/
void a2tvprst(PCB *pcb);
/*a2tvpset-setting of picture parameters without displaying*/
void a2tvpset(PCB *part);
/*----------- a2tvchnw - window size changing -------------*/
a2tvchnw(WCB *pwcb, TINT *coor, TINT *size, int *regim);
   /* pwcb - pointer to window; coor - dispalay coordinates;
      size - maximum sizes; regim: R_SZ - size changing
      R_CR - coordinate changing, R_DS - description changing
      R_CP - copying, R_DL- deleting, R_NO - empty.
   */
/*----------- a2tvprtw - display picture window -----------*/
void a2tvprtw(PCB *pcb, WCB *wcb, unsigned char *color);
/*------------ a2tvwint - setting of window displacements -*/
a2tvwint(WCB *wcb);
/*----------- a2tvpart - display document picture ---------*/
void a2tvpart(PCB *tpcb);
/*-------------- a2tvmenu - menu processing ---------------*/
a2tvmenu(PCB *mpcb, char *menu, int lvclr);
/* level from 1 and up; set from 0 and up */
/*------ a2mnukset - setting character codes for menu -----*/
a2mnukset(int key);/* sets key kode for a2tvmenu ----------*/
/*---- a2setkout - set Alt codes, when picture ...     ----*/
void a2setkout(PCB *pcb, WCB *wcb);
/* pcb - picture, wcb - window with text                   */
/*=========================================================*/
/* ind - pointer to window identifyer; type - window       */
/* identifyer type, takes a value: s - name beginning      */
/* c - whole name, i - window number, n - as 's', but      */
/* search from current window, w - pointer to window ;     */
/*=========================================================*/
/*--- a2wcbfnd - search for window by indentifyer ---------*/
WCB *a2wcbfnd(PCB *pcb, char type, void *ind);
/* type:s/c/i/n, ind:name beginning/name/number/next on s  */
/*------------- a2wcbopn - open window for writing --------*/
a2wcbopn(PCB *pcb, char type, void *ind);
/* type: s/c/i - type, ind - name beginning/name/window number */
/*------------- a2wcbcls - close window for writing --------*/
a2wcbcls(PCB *pcb, char type, void *ind);
/* type: s/c/i - type, ind - name beginning/name/window number */
/*--------- a2wcbcl1 - change non-active color in window ---*/
a2wcbcl1(PCB *pcb, char type, void *ind, char clr);
/* type: s/c/i - type, ind - name beginning/name/window number */
/*----------- a2fwcbdn - search for open window in bottom -*/
WCB *a2fwcbdn(PCB *pcb, WCB *wcb);
/*--------- a2fwcbup - search for open window in top ------*/
WCB *a2fwcbup(PCB *pcb, WCB *wcb);
/*-------------- a2tvwinn - value writing into window -----*/
a2tvwinn(PCB *pcb, char td, void *data, char tw, void *ind);
/* data - value; td - value type: TY_...; tw: - window search
   method: s/c/i; ind - pointer to name, name beginning or
   window number ( depends on search method )
*/
/*------- a2tvwind - puts value and displays window -------*/
a2tvwind(PCB *pcb, char td, void *data, char tw, void *ind);
/* data - value; td - value type: TY_...; tw: - window search
   method: s/c/i; ind - pointer to name, name beginning or
   window number ( depends on search method )
*/
/*-------- a2ptwput - data writing to model picture -------*/
a2ptwput(char rgm, PCB *prt, ...);
/* type, value, ... TY_RQ, ind, ..., TY_RQS, ind, ..., TY_M
   rgm=[GW_CURR|][GW_NOCLS|][GW_NOOPN|][GW_NOSYS|][GW_DSPL]
   - regime; type - as for data type conversion block (a2conv)
   and special data types: TY_M - end of parameter list,
  TY_RQ - search for 1-st window on prefix starting from current,
  TY_RQS - further processing only on prefix               */
/*----- a2tvfset - setting of exit function for window ----*/
a2tvfset(PCB *pcb,
	int flags, int (*f)(PFUS *pfus), char tw, void *ind);
/*function type, function, identifyer type, window identifyer
  function type: WF_FCI, WF_FCO, WF_FCH, WF_F2 or 0 (special function)
  identifyer type: i, s, c, p */
/*--------------- a2tvclrw - clearing of window -----------*/
void a2tvclrw(WCB *wcb);
/*-- a2tvclrp - clearing of windows for document picture --*/
void a2tvclrp(PCB *tpcb);

#define TY_NC 98
#define TY_NI 97

/*------------ a2tvwget - reading value from window -------*/
a2tvwget(PCB *pcb, char td, void *data, char tw, void *ind);
/* data - value; td - value type: TY_..., TY_NC - window name,
  TY_NI - window number; tw: - window search method: s/c/i;
   ind - pointer to name, name beginning or
   window number ( depends on search method )
*/
/*-------- a2pfwget - data reading from model  ------------*/
a2pfwget(char rgm, PCB *prt, ...);
/*  rgm=[GW_CURR|][GW_NOCLS|][GW_NOOPN|][GW_NOSYS|][GW_DSPL]
   - regime; type - as for data type conversion block (a2conv)
   and special data types: TY_M - end of parameter list,
  TY_RQ - search for 1-st window on prefix starting from current,
  TY_RQS - further processing only on prefix               */
/*--------- a2tvread - picture fulfillment in dialogue ----*/
a2tvread(PCB *pcb, char *name);
/*------- a2chelpw - window formatting for list  ----------*/
WCB *a2chelpw(PCB *pcb, int i, int j);
/* i - number of lines in list, j - window width */
/*---- a2dhelpw - dialogue processing on F2 key -----------*/
a2dhelpw(char flg, WCB *whelp, void *data);
#define WH_T      0x01                       /* text field */
#define WH_I      0x02                       /* int number */
#define WH_W      0x04                           /* window */
#define WH_P      0x08                          /* picture */
#define WH_STR    0x10                             /* save */
#define WH_RES    0x20                          /* recover */
/* whelp: window with list, flg: flags WH_...  */
/*---------- a2findfl - search for file name --------------*/
a2findfl(PFUS *pfus);
/*------ a2tvcirc() - circuit of picture windows list -----*/
void a2tvcirc(PCB *pcb);
/*---------- a2wndcir - circuit of text in circle ---------*/
void a2wndcir(LDSC *ldsc);
/*------ a2mpchsz - creation/updating of model picture ----*/
a2mpchsz(PCB *part, TINT *size, int *regim, LDSC *altc);
   /* part - pointer to picture; size - maximum sizes;
   regim: R_SZ - size changing, R_CR - coordinate changing,
          R_DS - description changing, R_CP - copying,
          R_DL- deleting, R_NO - empty;
    altc - list of exit codes.
   */
/*----- a2getdsc - gets description of separate window ----*/
a2getdsc(WCB *wcb,TINT *wcor);
/* wcb - window description, wcor - window coordinates     */
/*--- a2wcbget - memory allocation and WCB initialization -*/
WCB *a2wcbget(char *idpgm);
/* idpgm - identifyer of program, requesting WCB return    */
/* NULL - no memory for window; wcb - WCB created          */
/*--- a2pcbget - memory allocation and PCB initialization -*/
PCB *a2pcbget(char *idpgm);
/* idpgm - identyfyer of program, requesting PCB return    */
/* NULL - no memory for picture; wcb - PCB created         */
/*-------- a2wcbfre - memory releasing from WCB -----------*/
WCB *a2wcbfre(WCB *wcb, char *idpgm);
/* idpgm - identifyer of program, passing WCB,             */
/* returns NULL                                            */
/*------- a2pcbfre - memory releasing from picture --------*/
PCB *a2pcbfre(PCB *pcb, char *idpgm);
/* idpgm - identifyer of program, passing PCB,             */
/* returns NULL                                            */
/*------------- a2wcbcpy - creation of window copy --------*/
WCB *a2wcbcpy(WCB *old, char *idpgm);
/* idpgm - identifyer of program, requesting copy,         */
/* returns pointer to copy or NULL if no memory            */
/*------ a2pcbcpy - creation of document picture copy -----*/
PCB *a2pcbcpy(PCB *old, char *idpgm);
/* idpgm - identifyer of program, requesting copy,         */
/* returns pointer to copy or NULL if no memory            */
/*--- a2docget - memory allocation and DOC initialization -*/
DOC *a2docget(char *idpgm);
/* idpgm - identifyer of program, requesting DOC,          */
/* returns pointer to DOC or NULL if no memory             */
/*-------- a2docfre - memory releasing from DOC -----------*/
DOC *a2docfre(DOC *doc, char *idpgm);
/* idpgm - identifyer of program, passing DOC,             */
/* returns NULL                                            */
/*--------- a2mpfree - pushing out of model picture -------*/
PCB *a2mpfree(PCB *pcb, char *idpgm);
/* releas model picture with all windows                   */
/* pcb - pointer to model, idpgm - program identifyer      */
/*----------- a2mpcrea - creation of model picture --------*/
PCB *a2mpcrea(char *pname);
/* returns: NULL-no memory for picture; pcb-picture created*/
/*---------- a2tvdoc - displaying of document -------------*/
void a2tvdoc(DOC *doc);
/*------------- a2clrdoc - clearing of document windows ---*/
void a2clrdoc(DOC *doc);
/*------ a2pcbfnd - search picture on identifyer ----------*/
PCB *a2pcbfnd(DOC *doc, char type, void *ind);
/* type:s/c/i/n, ind:name beginning/name/number/next on s  */
/*---- a2rddoc - dialogue fulfillment of pictures group ---*/
a2rddoc(DOC *doc, char *pnm, char *wnm);
/* carry out dialogue starting from picture *name or from
   current (NULL)
 */
/*------ a2mdfree - pushing out of document model ---------*/
DOC *a2mdfree(DOC *doc, char *idpgm);
/* releases document model with all windows                */
/*doc - pointer to model, idpgm - program identifyer       */
/*--- a2frcbgt - memory allocation for FRCB ---------------*/
FRCB *a2frcbgt(char *idpgm);
/* idpgm - identifyer of program, reqesting FRCB,          */
/* returns pointer to FRCB or NULL if no memory            */
/*-------- a2frcbfr - releasing memory from FRCB ----------*/
FRCB *a2frcbfr(FRCB *frcb, char *idpgm);
/* idpgm - identifyer of program, passing FRCB,            */
/* returns NULL                                            */

a2WinAsPart(PFUS *pu) ;
PCB *a2GetPartForWin(PCB *pcb, WCB *wcb) ;
PCB *a2GetPartForName(PCB *pcb, char *nameW) ;
#define GetPartForWina 2GetPartForWin
#define GetPartForName a2GetPartForName
void a2SetSpecWin(PCB *pcb, int (*fUserSet)(WCB *, char *)) ;
#ifdef __cplusplus
}
#endif
/*-------------- MAIN MACROOPERATIONS ---------------------*/
/* is there data in window ? */
#define YESDT(W) \
         (W!=NULL && W->text!=NULL && W->text->text[0]!='\0')

#ifndef DEF_TINT_MACROS
#define DEF_TINT_MACROS
# define GETWIN(x)       MOVETINT(x.p,window.p); MOVETINT(x.s,window.s)
# define MOVETINT(x,y)   x=y
# define SUBTTINT(z,x,y) z.row=(int)(x.row-y.row); z.clm=(int)(x.clm-y.clm)
# define ADDTINT(z,x,y)  z.row=(int)(x.row+y.row); z.clm=(int)(x.clm+y.clm)
# define SETTINT(x,a,b)  x.row=a; x.clm=b
#endif

#define SETLDSC(ld,dn,ud,txt)   \
 ld.text=txt; ld.szline=0; ld.next=NULL; ld.up=ud; ld.down=dn
#define SETWCB(w,tx,nx,pr,nm,hl,sq)  \
  w.text=tx; w.next=nx; w.prev=pr; w.name=nm; w.help=hl; w.admch=sq
#define SETPCB(pt,x,wp,ws,pn,pp) \
 pt.flags=x; pt.part=wp; pt.fwindow=ws; pt.twindow=ws; \
 pt.next=pn; pt.prev=pp
/*------------- LDSC with text initialization -------------*/
#define ILDSC(ld,txt) \
static LDSC ld={txt,0,NULL,NULL,NULL}
/*------ LDSC with text and refernce initialization -------*/
#define ISLDSC(ld,next,txt) \
static LDSC ld={txt,0,NULL,NULL,next}
/*---------------------------------------------------------*/
/*---------- is window type undefined ---------------------*/
#define IS_UNDEF(win)  \
  ((win)->fch!=NULL && \
  ((win)->flags&(WF_FCI|WF_FCO|WF_FCH|WF_F2))==0)
/*---------------------------------------------------------*/

#endif
